package com.yuyou.activity.util.util;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.RandomStringUtils;

import com.google.common.base.Charsets;

public class TokenUtil {

	private static final String PREFIX="TAS_";
	
	public static String GenerateToken(){
        String token = PREFIX+RandomStringUtils.randomAlphabetic(18);
        token = Base64.encodeBase64URLSafeString(token.getBytes(Charsets.UTF_8)).toLowerCase();
        return token;
	}
	
	public static String randomAlphabetic(int num){
        String token = RandomStringUtils.randomAlphabetic(num).toLowerCase();       
        return token;
	}
	
	public static void main(String[] args) {
		System.out.println(TokenUtil.GenerateToken());
		System.out.println(TokenUtil.randomAlphabetic(6));
	}
	
	
}
